package com.epichust.bootuqc.controller;

import com.epichust.bootuqc.model.bo.ReturnBO;
import com.epichust.bootuqc.model.entity.Uqcm5ChkBillCitemD;
import com.epichust.bootuqc.service.IUqcm5ChkBillCitemDService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * Description:
 *
 * @author:伦伦的电脑
 * @date: 2021/2/23 9:57
 */
@RestController
@RequestMapping("api/chkcitemd")
public class Uqcm5ChkBillCitemDController {
    @Autowired
    IUqcm5ChkBillCitemDService iuqcm5chkbillcitemdservice;
    @RequestMapping(value = "/getAll", method = {RequestMethod.POST})
    public String getAllUqcm5ChkBillCitemD(@RequestBody Map<String,Object> map){
        try{
            // 新建返回对象
            Gson gson = new GsonBuilder().serializeNulls().create();
            ReturnBO bo = new ReturnBO();
            List<Uqcm5ChkBillCitemD> list = iuqcm5chkbillcitemdservice.getAllUqcm5ChkBillCitemD(map);
            bo.setState(0);
            bo.setObject(list);
            return gson.toJson(bo);
        }catch (Exception e){
            // 新建返回对象
            Gson gson = new GsonBuilder().serializeNulls().create();
            ReturnBO bo = new ReturnBO();
            bo.setState(1);
            bo.setObject("查询失败："+e.getMessage());
            return gson.toJson(bo);
        }
    }
    @RequestMapping(value = "/save", method = {RequestMethod.POST})
    public String saveUqcm5ChkBillCitemD(@RequestBody Uqcm5ChkBillCitemD uqcm5chkbillcitemd){
        try{
            // 新建返回对象
            Gson gson = new GsonBuilder().serializeNulls().create();
            ReturnBO bo = new ReturnBO();
            iuqcm5chkbillcitemdservice.insertUqcm5ChkBillCitemD(uqcm5chkbillcitemd);
            bo.setState(0);
            bo.setObject("保存成功");
            return gson.toJson(bo);
        }catch (Exception e){
            // 新建返回对象
            Gson gson = new GsonBuilder().serializeNulls().create();
            ReturnBO bo = new ReturnBO();
            bo.setState(1);
            bo.setObject("保存失败："+e.getMessage());
            return gson.toJson(bo);
        }
    }
}
